home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / ULARN.ARJ / ULARN.TAR / ularn / object.c < prev    next >
C/C++ Source or Header  |  1989-10-25  |  32KB  |  1,545 lines

  1. /*    object.c        */
  2.  
  3.  
  4. #include "header.h"
  5.  
  6. /*
  7.     ***************
  8.     LOOK_FOR_OBJECT
  9.     ***************
  10.  
  11.     subroutine to look for an object and give the player his options
  12.     if an object was found.
  13.  */
  14. lookforobject()
  15. {
  16.     register int i,j;
  17.  
  18.     /* can't find objects is time is stopped*/
  19.     if (c[TIMESTOP])  return;    
  20.  
  21.     i=item[playerx][playery];    
  22.     if (i==0) return;
  23.  
  24.     showcell(playerx,playery);  
  25.     cursors();  
  26.     yrepcount=0;
  27.  
  28.     switch(i) {
  29.     case OGOLDPILE:    
  30.     case OMAXGOLD:
  31.     case OKGOLD:    
  32.     case ODGOLD:    
  33.         lprcat("\n\nYou have found some gold!");    
  34.         ogold(i);    
  35.         break;
  36.  
  37.     case OPOTION:    
  38.         lprcat("\n\nYou have found a magic potion");
  39.         i = iarg[playerx][playery];
  40.         if (potionname[i][0]) lprintf(" of %s",&potionname[i][1]);  
  41.         opotion(i);  
  42.         break;
  43.  
  44.     case OSCROLL:    
  45.         lprcat("\n\nYou have found a magic scroll");
  46.         i = iarg[playerx][playery];
  47.         if (scrollname[i][0])    lprintf(" of %s",&scrollname[i][1]);
  48.         oscroll(i);  
  49.         break;
  50.  
  51.     case OALTAR:    
  52.         if (nearbymonst()) return;
  53.         lprcat("\n\nThere is a Holy Altar here!"); 
  54.         oaltar(); 
  55.         break;
  56.  
  57.     case OBOOK:    
  58.         lprcat("\n\nYou have found a book."); 
  59.         obook(); 
  60.         break;
  61.  
  62.     case OCOOKIE:    
  63.         lprcat("\n\nYou have found a fortune cookie."); 
  64.         ocookie(); 
  65.         break;
  66.  
  67.     case OTHRONE:    
  68.         if (nearbymonst()) return;
  69.         lprintf("\n\nThere is %s here!",objectname[i]); 
  70.         othrone(0); 
  71.         break;
  72.  
  73.     case OTHRONE2:    
  74.         if (nearbymonst()) return;
  75.         lprintf("\n\nThere is %s here!",objectname[i]); 
  76.         othrone(1); 
  77.         break;
  78.  
  79.     case ODEADTHRONE: 
  80.         lprintf("\n\nThere is %s here!",objectname[i]); 
  81.         odeadthrone(); 
  82.         break;
  83.  
  84.     case OORB:    
  85.         if (nearbymonst()) return;
  86.         finditem(i);
  87.         break;
  88.  
  89.     case OBRASSLAMP: 
  90.         lprcat("\nYou have found a brass lamp ");
  91.     lprcat("\nDo you want to (r) rub it, (t) take it, or (i) ignore it? ");
  92.         i=0;
  93.         while ((i!='r') && (i!='i') && (i!='t') && (i!='\33')) 
  94.             i=getcharacter();
  95.         if (i=='r') {
  96.             i=rnd(100);
  97.             if (i>90) {
  98.         lprcat("\nThe magic genie was very upset at being disturbed!");
  99.                 losehp((int)c[HP]/2+1);
  100.                 beep();
  101.             }
  102.             /* higher level, better chance of spell */
  103.             else if ( (rnd(100)+c[LEVEL]/2) > 80) {
  104.                 register int a,b,d;
  105.                 lprcat("\nA magic genie appears!");
  106.                 cursors();
  107.                 lprcat("\n  What spell would you like? : ");
  108.                 while ((a=getcharacter())=='D') {     
  109.                     seemagic(99);
  110.                     cursors();  
  111.                    lprcat("\n  What spell would you like? : ");
  112.                 }
  113.                 /* to escape casting a spell    */
  114.                 if (a=='\33') goto over;     
  115.                 if ((b=getcharacter())=='\33') 
  116.                     goto over;
  117.                 if ((d=getcharacter())=='\33') { 
  118. over: 
  119.                     lprcat("aborted"); 
  120.                     return;
  121.                 }
  122.                 for (lprc('\n'),i=0; i<SPNUM+1; i++)
  123.                     if ((spelcode[i][0]==a) 
  124.                         && (spelcode[i][1]==b) 
  125.                         && (spelcode[i][2]==d)) {
  126.                         spelknow[i]=1;
  127.             lprintf("\nSpell \"%s\":  %s\n%s",spelcode[i],
  128.                     spelname[i],speldescript[i]); 
  129.             lprcat("\nThe genie prefers not to be disturbed again");
  130.                         forget();
  131.                         bottomline();
  132.                         return;
  133.                     }
  134.             lprcat("\nThe genie has never heard of such a spell!");
  135.             lprcat("\nThe genie prefers not to be disturbed again");
  136.                 forget();
  137.                 bottomline();
  138.                 return;
  139.             }
  140.             else lprcat("\nnothing happened");
  141.             if (rnd(100) < 15) {
  142.         lprcat("\nThe genie prefers not to be disturbed again!");
  143.                 forget();
  144.                 c[LAMP]=0;  /* chance of finding lamp again */
  145.             }
  146.             bottomline();
  147.         }
  148.         else if (i=='t') {
  149.             lprcat("take");
  150.             if (take(OBRASSLAMP,0)==0) forget();
  151.         }
  152.         else lprcat("ignore");
  153.         return;
  154.  
  155.     case OWWAND:
  156.         if (nearbymonst()) return;
  157.         finditem(i);
  158.         break;
  159.  
  160.     case OHANDofFEAR:
  161.         if (nearbymonst()) return;
  162.         finditem(i);
  163.         break;
  164.  
  165.     case OPIT:    
  166.         lprcat("\n\nYou're standing at the top of a pit."); 
  167.         opit(); 
  168.         break;
  169.  
  170.     case OSTAIRSUP:    
  171.         lprcat("\n\nThere is a circular staircase here"); 
  172.         ostairs(1);  /* up */
  173.         break;
  174.  
  175.     case OELEVATORUP:
  176.         lprcat("\n\nYou have found an express elevator going up");
  177.         nap(2000);
  178.         oelevator(1);  /*  up  */
  179.  
  180.         break;
  181.  
  182.     case OELEVATORDOWN:    
  183.         lprcat("\n\nYou have found an express elevator going down");
  184.         nap(2000);
  185.         oelevator(-1);    /*    down    */
  186.         break;
  187.  
  188.     case OFOUNTAIN:    
  189.         if (nearbymonst()) return;
  190.         lprcat("\n\nThere is a fountain here"); 
  191.         ofountain(); 
  192.         break;
  193.  
  194.     case OSTATUE:    
  195.         if (nearbymonst()) return;
  196.         lprcat("\n\nYou are standing in front of a statue"); 
  197.         ostatue(); 
  198.         break;
  199.  
  200.     case OCHEST:    
  201.         lprcat("\n\nThere is a chest here");  
  202.         ochest();  
  203.         break;
  204.  
  205.     case OIVTELETRAP:    
  206.         if (rnd(11)<6) return;
  207.         item[playerx][playery] = OTELEPORTER;
  208.         know[playerx][playery] = 1;
  209.  
  210.     case OTELEPORTER:
  211.         lprcat("\nZaaaappp!  You've been teleported!\n");
  212.         beep(); 
  213.         nap(3000); 
  214.         oteleport(0);
  215.         break; 
  216.  
  217.     case OSCHOOL:    
  218.         if (nearbymonst()) return;
  219.         lprcat("\n\nYou have found the College of Ularn.");
  220.         lprcat("\nDo you (g) go inside, or (i) stay here? ");
  221.         i=0; 
  222.         while ((i!='g') && (i!='i') && (i!='\33')) i=getcharacter();
  223.         if (i == 'g') { 
  224.             oschool();  /*    the college of larn    */
  225.         }
  226.         else    lprcat(" stay here");
  227.         break;
  228.  
  229.     case OMIRROR:    
  230.         if (nearbymonst()) return;
  231.         lprcat("\n\nThere is a mirror here");    
  232.         omirror();    
  233.         break;
  234.  
  235.     case OBANK2:
  236.     case OBANK:    
  237.         if (nearbymonst()) return;
  238.         if (i==OBANK) 
  239.             lprcat("\n\nYou have found the bank of Ularn.");
  240.         else 
  241.             lprcat("\n\nYou have found a branch office of the bank of Ularn.");
  242.         lprcat("\nDo you (g) go inside, or (i) stay here? ");
  243.         j=0; 
  244.         while ((j!='g') && (j!='i') && (j!='\33')) 
  245.             j=getcharacter();
  246.         if (j == 'g') {  
  247.             if (i==OBANK) 
  248.                 obank(); 
  249.             else 
  250.                 obank2(); /*  the bank of larn  */
  251.  
  252.         }
  253.         else   lprcat(" stay here");
  254.         break;
  255.  
  256.     case ODEADFOUNTAIN:    
  257.         if (nearbymonst()) return;
  258.         lprcat("\n\nThere is a dead fountain here"); 
  259.         break;
  260.  
  261.     case ODNDSTORE:    
  262.         if (nearbymonst()) return;
  263.         lprcat("\n\nThere is a DND store here.");
  264.         lprcat("\nDo you (g) go inside, or (i) stay here? ");
  265.         i=0; 
  266.         while ((i!='g') && (i!='i') && (i!='\33')) i=getcharacter();
  267.         if (i == 'g')
  268.             dndstore();  /*  the dnd adventurers store  */
  269.         else  lprcat(" stay here");
  270.         break;
  271.  
  272.     case OSTAIRSDOWN:
  273.         lprcat("\n\nThere is a circular staircase here"); 
  274.         ostairs(-1); /* down */
  275.         break;
  276.  
  277.     case OOPENDOOR:        
  278.         lprintf("\n\nYou have found %s",objectname[i]);
  279.         lprcat("\nDo you (c) close it"); 
  280.         iopts();
  281.         i=0; 
  282.         while ((i!='c') && (i!='i') && (i!='\33')) i=getcharacter();
  283.         if ((i=='\33') || (i=='i')) { 
  284.             ignore();  
  285.             break; 
  286.         }
  287.         lprcat("close");  
  288.         forget();
  289.         item[playerx][playery]=OCLOSEDDOOR;
  290.         iarg[playerx][playery]=0;
  291.         playerx = lastpx;  
  292.         playery = lastpy;
  293.         break;
  294.  
  295.     case OCLOSEDDOOR:    
  296.         lprintf("\n\nYou have found %s",objectname[i]);
  297.         lprcat("\nDo you (o) try to open it"); 
  298.         iopts();
  299.         i=0; 
  300.         while ((i!='o') && (i!='i') && (i!='\33')) i=getcharacter();
  301.         if ((i=='\33') || (i=='i'))
  302.         { 
  303.             ignore();  
  304.             playerx = lastpx;
  305.             playery = lastpy; 
  306.             break; 
  307.         }
  308.         else
  309.         {
  310.             lprcat("open");
  311.             if (rnd(11)<7)
  312.             {
  313.                 switch(iarg[playerx][playery])
  314.                 {
  315.                 case 6: 
  316.                     c[AGGRAVATE] += rnd(400);    
  317.                     break;
  318.  
  319.                 case 7:    
  320.                     lprcat("\nYou are jolted by an electric shock "); 
  321.                     lastnum=274; 
  322.                     losehp(rnd(20));  
  323.                     bottomline();  
  324.                     break;
  325.  
  326.                 case 8:    
  327.                     loselevel();  
  328.                     break;
  329.  
  330.                 case 9:    
  331.                     lprcat("\nYou suddenly feel weaker ");
  332.                     if (c[STRENGTH]>3) c[STRENGTH]--;
  333.                     bottomline();  
  334.                     break;
  335.  
  336.                 default:    
  337.                     break;
  338.                 }
  339.                 playerx = lastpx;  
  340.                 playery = lastpy;
  341.             }
  342.             else
  343.             {
  344.                 forget();  
  345.                 item[playerx][playery]=OOPENDOOR;
  346.             }
  347.         }
  348.         break;
  349.  
  350.     case OENTRANCE:    
  351.         lprcat("\nYou have found "); 
  352.         lprcat(objectname[OENTRANCE]);
  353.         lprcat("\nDo you (g) go inside"); 
  354.         iopts();
  355.         i=0; 
  356.         while ((i!='g') && (i!='i') && (i!='\33')) i=getcharacter();
  357.         if (i == 'g')
  358.         {
  359.             newcavelevel(1); 
  360.             playerx=33; 
  361.             playery=MAXY-2;
  362.             item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0;
  363.             draws(0,MAXX,0,MAXY); 
  364.             bot_linex(); 
  365.             return;
  366.         }
  367.         else   ignore();
  368.         break;
  369.  
  370.     case OVOLDOWN:    
  371.         lprcat("\nYou have found "); 
  372.         lprcat(objectname[OVOLDOWN]);
  373.         lprcat("\nDo you (c) climb down"); 
  374.         iopts();
  375.         i=0; 
  376.         while ((i!='c') && (i!='i') && (i!='\33')) 
  377.             i=getcharacter();
  378.         if ((i=='\33') || (i=='i')) { 
  379.             ignore();  
  380.             break; 
  381.         }
  382.         if (level!=0) 
  383.         { 
  384.             lprcat("\nThe shaft only extends 5 feet downward!"); 
  385.             return; 
  386.         }
  387.         if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) 
  388.         { 
  389.             lprcat("\nYou slip and fall down the shaft"); 
  390.             beep();
  391.             lastnum=275;  
  392.             losehp(30+rnd(20)); 
  393.             bottomhp(); 
  394.         }
  395.         else lprcat("climb down");  
  396.         nap(3000); 
  397.         newcavelevel(MAXLEVEL);
  398.         playerx = rnd(MAXX-2);
  399.         playery = rnd(MAXY-2);
  400.         positionplayer(); 
  401.         draws(0,MAXX,0,MAXY); 
  402.         bot_linex(); 
  403.         return;
  404.  
  405.     case OVOLUP:    
  406.         lprcat("\nYou have found "); 
  407.         lprcat(objectname[OVOLUP]);
  408.         lprcat("\nDo you (c) climb up"); 
  409.         iopts();
  410.         i=0; 
  411.         while ((i!='c') && (i!='i') && (i!='\33')) i=getcharacter();
  412.         if ((i=='\33') || (i=='i')) { 
  413.             ignore();  
  414.             break; 
  415.         }
  416.     if (packweight() > 40+5*(c[DEXTERITY]+c[STRENGTH]+c[STREXTRA])) { 
  417.             lprcat("\nYou slip and fall down the shaft"); 
  418.             beep();
  419.             lastnum=275; 
  420.             losehp(15+rnd(20)); 
  421.             bottomhp(); 
  422.             return; 
  423.         }
  424.         lprcat("climb up"); 
  425.         lflush(); 
  426.         nap(3000); 
  427.         newcavelevel(0);
  428.         for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++) /* put player near volcano shaft */
  429.             if (item[j][i]==OVOLDOWN) { 
  430.                 playerx=j; 
  431.                 playery=i; 
  432.                 j=MAXX; 
  433.                 i=MAXY; 
  434.                 positionplayer(); 
  435.             }
  436.         draws(0,MAXX,0,MAXY); 
  437.         bot_linex(); 
  438.         return;
  439.  
  440.     case OTRAPARROWIV:    
  441.         if (rnd(17)<13) return;    /* for an arrow trap */
  442.         item[playerx][playery] = OTRAPARROW;
  443.         know[playerx][playery] = 0;
  444.     case OTRAPARROW:    
  445.         lprcat("\nYou are hit by an arrow"); 
  446.         beep();    /* for an arrow trap */
  447.         lastnum=259;    
  448.         losehp(rnd(10)+level);
  449.         bottomhp();    
  450.         return;
  451.  
  452.     case OIVDARTRAP:    
  453.         if (rnd(17)<13) 
  454.             return;        /* for a dart trap */
  455.         item[playerx][playery] = ODARTRAP;
  456.         know[playerx][playery] = 0;
  457.     case ODARTRAP:        
  458.         lprcat("\nYou are hit by a dart"); 
  459.         beep();    /* for a dart trap */
  460.         lastnum=260;    
  461.         losehp(rnd(5));
  462.         if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3;
  463.         bottomline();    
  464.         return;
  465.  
  466.     case OIVTRAPDOOR:    
  467.         if (rnd(17)<13) 
  468.             return;        /* for a trap door */
  469.         item[playerx][playery] = OTRAPDOOR;
  470.         know[playerx][playery] = 1;
  471.     case OTRAPDOOR:        
  472.         lastnum = 272; /* a trap door */
  473.         for (i=0;i<26;i++)
  474.             if (iven[i]==OWWAND) {
  475.                 lprcat("\nYou escape a trap door");
  476.                 return;
  477.             }
  478.         if ((level==MAXLEVEL-1)||(level==MAXLEVEL+MAXVLEVEL-1))
  479.         { 
  480.             lprcat("\nYou fell through a trap door leading straight to HELL!");               
  481.             beep();  
  482.             nap(3000);  
  483.             died(271); 
  484.         }
  485.         lprcat("\nYou fall through a trap door!"); 
  486.         beep();    
  487.         losehp(rnd(5+level));
  488.         nap(2000);
  489.         newcavelevel(level+1);  
  490.         draws(0,MAXX,0,MAXY); 
  491.         bot_linex();
  492.         return;
  493.  
  494.     case OTRADEPOST:
  495.         if (nearbymonst()) return;
  496.         lprcat("\nYou have found the Ularn trading Post.");
  497.         lprcat("\nDo you (g) go inside, or (i) stay here? ");
  498.         i=0; 
  499.         while ((i!='g') && (i!='i') && (i!='\33')) i=getcharacter();
  500.         if (i == 'g')  otradepost();  
  501.         else  lprcat("stay here");
  502.         return;
  503.  
  504.     case OHOME:    
  505.         if (nearbymonst()) return;
  506.         lprcat("\nYou have found your way home.");
  507.         lprcat("\nDo you (g) go inside, or (i) stay here? ");
  508.         i=0; 
  509.         while ((i!='g') && (i!='i') && (i!='\33')) 
  510.             i=getcharacter();
  511.         if (i == 'g')  
  512.             ohome();  
  513.         else  lprcat("stay here");
  514.         return;
  515.     case OPAD:    
  516.         if (nearbymonst()) return;
  517.         lprcat("\nYou have found Dealer McDope's Hideout!!");
  518.         lprcat("\nDo you (c) check it out, or (i) ignore it? ");
  519.         i=0;
  520.         while ((i!='c') && (i!='i') && (i!='\33')) 
  521.             i=getcharacter();
  522.         if (i == 'c')  
  523.             opad();
  524.         else  lprcat("forget it");
  525.         return;
  526.  
  527.     case OSPEED:       
  528.         lprcat("\nYou have found some speed");
  529.         lprcat("\nDo you (s) snort it, (t) take it, or (i) ignore it? ");
  530.         i=0; 
  531.         while ((i!='s') && (i!='i') && (i!='t') && (i!='\33')) 
  532.             i=getcharacter();
  533.         if (i=='s') {
  534.             lprcat("snort!");
  535.             lprcat("\nOhwowmanlikethingstotallyseemtoslowdown!");
  536.             c[HASTESELF] += 200 + c[LEVEL];
  537.             c[HALFDAM] += 300 + rnd(200);
  538.             if ((c[INTELLIGENCE]-=2) < 3)
  539.                 c[INTELLIGENCE]=3;
  540.             if ((c[WISDOM]-=2) < 3)
  541.                 c[WISDOM]=3;
  542.             if ((c[CONSTITUTION]-=2) <3)
  543.                 c[CONSTITUTION]=3;
  544.             if ((c[DEXTERITY]-=2) <3)
  545.                 c[DEXTERITY]=3;
  546.             if ((c[STRENGTH]-=2) <3)
  547.                 c[STRENGTH]=3;
  548.             forget();
  549.             bottomline();
  550.         } 
  551.         else if (i=='t') {
  552.             lprcat("take");
  553.             if (take(OSPEED,0)==0) forget();
  554.         } 
  555.         else 
  556.             lprcat("ignore"); 
  557.         break;
  558.  
  559.     case OSHROOMS:    
  560.         lprcat("\nYou have found some magic mushrooms");
  561.         lprcat("\nDo you (e) eat them, (t) take them, or (i) ignore them? ");
  562.         i=0; 
  563.         while ((i!='e') && (i!='i') && (i!='t') && (i!='\33')) 
  564.             i=getcharacter();
  565.         if (i=='e') {
  566.             lprcat("eat!");
  567.             lprcat("\nThings start to get real spacey...");
  568.             c[HASTEMONST] += rnd(75) + 25;
  569.             c[CONFUSE] += 30+rnd(10);
  570.             c[WISDOM]+=2;
  571.             c[CHARISMA]+=2;
  572.             forget();
  573.             bottomline();
  574.         } 
  575.         else if (i=='t') {
  576.             lprcat("take");
  577.             if (take(OSHROOMS,0)==0) forget();
  578.         } 
  579.         else
  580.             lprcat("ignore");
  581.         break;
  582.  
  583.     case OACID:    
  584.         lprcat("\nYou have found some LSD");
  585.         lprcat("\nDo you (e) eat it, (t) take it, or (i) ignore it? ");
  586.         i=0; 
  587.         while ((i!='e') && (i!='i') && (i!='t') && (i!='\33')) 
  588.             i=getcharacter();
  589.         if (i=='e') {
  590.             lprcat("eat!");
  591.             lprcat("\nYou are now frying your ass off");
  592.             c[CONFUSE]+=30+rnd(10);
  593.             c[WISDOM]+=2;
  594.             c[INTELLIGENCE]+=2;
  595.             c[AWARENESS]+=1500;
  596.             c[AGGRAVATE]+=1500;
  597.             {     
  598.                 int j,k;    /* heal monsters */
  599.                 for(j=0;j<MAXY;j++)
  600.                     for(k=0;k<MAXX;k++)
  601.                         if (mitem[k][j])
  602.                             hitp[k][j]=monster[mitem[k][j]].hitpoints;
  603.             }
  604.             forget();
  605.             bottomline();
  606.         }
  607.         else if (i=='t') {
  608.             lprcat("take");
  609.             if (take(OACID,0)==0) forget();
  610.         }
  611.         else lprcat("ignore");
  612.         break;
  613.  
  614.     case OHASH:    
  615.         lprcat("\nYou have found some hashish");
  616.         lprcat("\nDo you (s) smoke it, (t) take it, or (i) ignore it? ");
  617.         i=0; 
  618.         while ((i!='s') && (i!='i') && (i!='t') && (i!='\33')) 
  619.             i=getcharacter();
  620.         if (i=='s') {
  621.             lprcat("smoke!");
  622.             lprcat("\nWOW! You feel stooooooned...");
  623.             c[HASTEMONST]+=rnd(75)+25;
  624.             c[INTELLIGENCE]+=2;
  625.             c[WISDOM]+=2;
  626.             if( (c[CONSTITUTION]-=2) < 3) 
  627.                 c[CONSTITUTION]=3;
  628.             if( (c[DEXTERITY]-=2) < 3) 
  629.                 c[DEXTERITY]=3;
  630.             c[HALFDAM]+=300+rnd(200);
  631.             c[CLUMSINESS]+=rnd(1800)+200;
  632.             forget();
  633.             bottomline();
  634.         }
  635.         else if (i=='t') {
  636.             lprcat("take");
  637.             if (take(OHASH,0)==0) forget();
  638.         }
  639.         else lprcat("ignore");
  640.         break;
  641.  
  642.     case OCOKE:    
  643.         lprcat("\nYou have found some cocaine");
  644.         lprcat("\nDo you want to (s) snort it, (t) take it, or (i) ignore it? ");
  645.         i=0; 
  646.         while ((i!='s') && (i!='i') && (i!='t') && (i!='\33')) 
  647.             i=getcharacter();
  648.         if (i=='s') {
  649.             lprcat("snort!");
  650.             lprcat("\nYour nose begins to bleed");
  651.             if ((c[DEXTERITY]-=2) <3)
  652.                 c[DEXTERITY]=3;
  653.             if ((c[CONSTITUTION]-=2) <3)
  654.                 c[CONSTITUTION]=3;
  655.             c[CHARISMA]+=3;
  656.             for(i=0;i<6;i++)
  657.                 c[i]+=33;
  658.             c[COKED]+=10;
  659.             forget();
  660.             bottomline();
  661.         }
  662.         else if (i=='t') {
  663.             lprcat("take");
  664.             if (take(OCOKE,0)==0) forget();
  665.         }
  666.         else lprcat("ignore");
  667.         break;    
  668.  
  669.     case OWALL:    
  670.         break;
  671.  
  672.     case OANNIHILATION:
  673.         for (i=0;i<26;i++)
  674.             if (iven[i]==OSPHTALISMAN) {
  675.                 lprcat("\nThe Talisman of the Sphere protects you from annihilation!");
  676.                 return;
  677.             }
  678.         /* annihilated by sphere of annihilation */    
  679.         died(283);
  680.         return;
  681.  
  682.     case OLRS:    
  683.         if (nearbymonst()) return;
  684.         lprcat("\n\nThere is an LRS office here.");
  685.         lprcat("\nDo you (g) go inside, or (i) stay here? ");
  686.         i=0; 
  687.         while ((i!='g') && (i!='i') && (i!='\33')) i=getcharacter();
  688.         if (i == 'g')
  689.             olrs();  /*  the larn revenue service */
  690.         else  lprcat(" stay here");
  691.         break;
  692.     default:    
  693.         finditem(i); 
  694.         break;
  695.     };
  696. }
  697.  
  698. /*
  699.     function to say what object we found and ask if player wants to take it
  700.  */
  701. finditem(itm)
  702. int itm;
  703. {
  704.     int tmp,i;
  705.     lprintf("\n\nYou have found %s ",objectname[itm]);
  706.     tmp=iarg[playerx][playery];
  707.     switch(itm)
  708.     {
  709.     case ODIAMOND:        
  710.     case ORUBY:            
  711.     case OEMERALD:
  712.     case OSAPPHIRE:        
  713.     case OSPIRITSCARAB:    
  714.     case OORBOFDRAGON:
  715.     case OORB:
  716.     case OHANDofFEAR:
  717.     case OWWAND:
  718.     case OCUBEofUNDEAD:    
  719.     case ONOTHEFT:    
  720.         break;
  721.  
  722.     default:
  723.         if (tmp>0) 
  724.             lprintf("+ %d",(long)tmp); 
  725.         else if (tmp<0) lprintf(" %d",(long)tmp);
  726.     }
  727.     lprcat("\nDo you want to (t) take it"); 
  728.     iopts();
  729.     i=0; 
  730.     while (i!='t' && i!='i' && i!='\33') i=getcharacter();
  731.     if (i == 't')
  732.     {    
  733.         lprcat("take");  
  734.         if (take(itm,tmp)==0)  
  735.             forget();    
  736.         return;    
  737.     }
  738.     ignore();
  739. }
  740.  
  741.  
  742. /*
  743.     *******
  744.     OSTAIRS
  745.     *******
  746.  
  747.     subroutine to process the stair cases
  748.     if dir > 0 then up else down
  749.  */
  750. ostairs(dir)
  751. int dir;
  752. {
  753.     register int k, x, y;
  754.  
  755.     lprcat("\nDo you (s) stay here  or  ");
  756.     if (dir > 0)    
  757.         lprcat("(u) go up?  ");    
  758.     else    
  759.         lprcat("(d) go down?  ");
  760.  
  761.     while (1) 
  762.         switch(getcharacter()) {
  763.         case '\33':
  764.         case 's':    
  765.         case 'i':    
  766.             lprcat("stay here");    
  767.             return;
  768.  
  769.         case 'u':    
  770.             lprcat("go up");
  771.             if (dir < 0)    
  772.                 lprcat("\nThe stairs don't go up!");
  773.             else
  774.                 if (level>=2 && level!=MAXLEVEL) {
  775.                     newcavelevel(level-1);
  776.                     for (x=0;x<MAXX;x++)
  777.                         for (y=0;y<MAXY;y++)
  778.                             if (item[x][y] == OSTAIRSDOWN) {
  779.                                 playerx=x;
  780.                                 playery=y;
  781.                                 x=MAXX;
  782.                                 y=MAXY;
  783.                             }
  784.                     draws(0,MAXX,0,MAXY); 
  785.                     bot_linex();
  786.                 }
  787.                 else lprcat("\nThe stairs lead to a dead end!");
  788.             return;
  789.  
  790.         case 'd':    
  791.             lprcat("go down");
  792.             if (dir > 0)    
  793.                 lprcat("\nThe stairs don't go down!");
  794.             else
  795.                 if ((level!=0) && (level!= (MAXLEVEL-1)) && 
  796.                     (level!=(MAXLEVEL-1 + MAXVLEVEL))) {
  797.                     newcavelevel(level+1);
  798.                     for (x=0;x<MAXX;x++)
  799.                         for (y=0;y<MAXY;y++)
  800.                             if (item[x][y] == OSTAIRSUP) {
  801.                                 playerx=x;
  802.                                 playery=y;
  803.                                 x=MAXX;
  804.                                 y=MAXY;
  805.                             }
  806.                     draws(0,MAXX,0,MAXY); 
  807.                     bot_linex();
  808.                 }
  809.                 else lprcat("\nThe stairs lead to a dead end!");
  810.             return;
  811.         };
  812. }
  813.  
  814.  
  815. /*
  816.     *********
  817.     OTELEPORT
  818.     *********
  819.  
  820.     subroutine to handle a teleport trap +/- 1 level maximum
  821.  */
  822. oteleport(err)
  823. int err;
  824. {
  825.     register int tmp;
  826.  
  827.     if (err) if (rnd(151)<3)  died(264);  /* stuck in a rock */
  828.  
  829.     /*show ?? on bottomline if been teleported    */
  830.     if (!wizard) c[TELEFLAG]=1;    
  831.  
  832.     if (level==0) 
  833.         tmp=0;
  834.     else if (level < MAXLEVEL) {     /* in dungeon */
  835.         tmp=rnd(5)+level-3; 
  836.         if (tmp>=MAXLEVEL) 
  837.             tmp=MAXLEVEL-1;
  838.         if (tmp<0) 
  839.             tmp=0; 
  840.     }
  841.     else {                 /* in volcano */
  842.         tmp=rnd(4)+level-2; 
  843.         if (tmp>=MAXLEVEL+MAXVLEVEL) 
  844.             tmp=MAXLEVEL+MAXVLEVEL-1;
  845.         if (tmp<MAXLEVEL) 
  846.             tmp=0; 
  847.     }
  848.     playerx = rnd(MAXX-2);
  849.     playery = rnd(MAXY-2);
  850.     if (level != tmp)
  851.         newcavelevel(tmp);  
  852.     positionplayer();
  853.     draws(0,MAXX,0,MAXY); 
  854.     bot_linex();
  855. }
  856.  
  857. /*
  858.     *******
  859.     OPOTION
  860.     *******
  861.     }
  862.     playerx = rnd(MAXX-2);    
  863.     playery = rnd(MAXY-2);
  864.     if (level != tmp)
  865.         newcavelevel(tmp);  
  866.     positionplayer();
  867.     draws(0,MAXX,0,MAXY); 
  868.     bot_linex();
  869. }
  870.  
  871. /*
  872.     *******
  873.     OPOTION
  874.     *******
  875.  
  876.     function to process a potion
  877.  */
  878. opotion(pot)
  879. int pot;
  880. {
  881.     lprcat("\nDo you (d) drink it, (t) take it"); 
  882.     iopts();
  883.     while (1) switch(getcharacter())
  884.     {
  885.     case '\33':
  886.     case 'i':    
  887.         ignore();  
  888.         return;
  889.  
  890.     case 'd':    
  891.         lprcat("drink\n");    
  892.         forget();    /*    destroy potion    */
  893.         quaffpotion(pot);        
  894.         return;
  895.  
  896.     case 't':    
  897.         lprcat("take\n");    
  898.         if (take(OPOTION,pot)==0)  forget();
  899.         return;
  900.     };
  901. }
  902.  
  903. /*
  904.     function to drink a potion
  905.  */
  906. quaffpotion(pot)
  907. int pot;
  908. {
  909.     register int i,j,k;
  910.     if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */
  911.     potionname[pot][0] = ' ';
  912.     switch(pot)
  913.     {
  914.     case 9: 
  915.         lprcat("\nYou feel greedy . . .");   
  916.         nap(2000);
  917.         for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  918.             if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD))
  919.             {
  920.                 know[j][i]=1; 
  921.                 show1cell(j,i);
  922.             }
  923.         showplayer();  
  924.         return;
  925.  
  926.     case 19: 
  927.         lprcat("\nYou feel greedy . . .");   
  928.         nap(2000);
  929.         for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  930.         {
  931.             k=item[j][i];
  932.             if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD)
  933.                 || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE))
  934.             {
  935.                 know[j][i]=1; 
  936.                 show1cell(j,i);
  937.             }
  938.         }
  939.         showplayer();  
  940.         return;
  941.  
  942.     case 20: 
  943.         c[HP] = c[HPMAX]; 
  944.         break;    /* instant healing */
  945.  
  946.     case 1:    
  947.         lprcat("\nYou feel better");
  948.         if (c[HP] == c[HPMAX])  raisemhp(1);
  949.         else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX];  
  950.         break;
  951.  
  952.     case 2:    
  953.         lprcat("\nSuddenly, you feel much more skillful!");
  954.         raiselevel();  
  955.         raisemhp(1); 
  956.         return;
  957.  
  958.     case 3:    
  959.         lprcat("\nYou feel strange for a moment"); 
  960.         c[rund(6)]++;  
  961.         break;
  962.  
  963.     case 4:    
  964.         lprcat("\nYou feel more self confident!");
  965.         c[WISDOM] += rnd(2);  
  966.         break;
  967.  
  968.     case 5:    
  969.         lprcat("\nWow!  You feel great!");
  970.         if (c[STRENGTH]<12) c[STRENGTH]=12; 
  971.         else c[STRENGTH]++;  
  972.         break;
  973.  
  974.     case 6:    
  975.         lprcat("\nYour charm went up by one!");  
  976.         c[CHARISMA]++;  
  977.         break;
  978.  
  979.     case 8:    
  980.         lprcat("\nYour intelligence went up by one!");
  981.         c[INTELLIGENCE]++;  
  982.         break;
  983.  
  984.     case 10: 
  985.         for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  986.             if (mitem[j][i])
  987.             {
  988.                 know[j][i]=1; 
  989.                 show1cell(j,i);
  990.             }
  991.         /*    monster detection    */  return;
  992.  
  993.     case 12: 
  994.         lprcat("\nThis potion has no taste to it");  
  995.         return;
  996.  
  997.     case 15: 
  998.         lprcat("\nWOW!!!  You feel Super-fantastic!!!");
  999.         if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11;
  1000.         c[HERO] += 250;  
  1001.         break;
  1002.  
  1003.     case 16: 
  1004.         lprcat("\nYou have a greater intestinal constitude!");
  1005.         c[CONSTITUTION]++;  
  1006.         break;
  1007.  
  1008.     case 17: 
  1009.         lprcat("\nYou now have incredibly bulging muscles!!!");
  1010.         if (c[GIANTSTR]==0) c[STREXTRA] += 21;
  1011.         c[GIANTSTR] += 700;  
  1012.         break;
  1013.  
  1014.     case 18: 
  1015.         lprcat("\nYou feel a chill run up your spine!");
  1016.         c[FIRERESISTANCE] += 1000;  
  1017.         break;
  1018.  
  1019.     case 0:    
  1020.         lprcat("\nYou fall asleep. . .");
  1021.         i=rnd(11)-(c[CONSTITUTION]>>2)+2;  
  1022.         while(--i>0) { 
  1023.             parse2();  
  1024.             nap(1000); 
  1025.         }
  1026.         cursors();  
  1027.         lprcat("\nYou woke up!");  
  1028.         return;
  1029.  
  1030.     case 7:    
  1031.         lprcat("\nYou become dizzy!");
  1032.         if (--c[STRENGTH] < 3) c[STRENGTH]=3;  
  1033.         break;
  1034.  
  1035.     case 11: 
  1036.         lprcat("\nYou stagger for a moment . .");
  1037.         for (i=0; i<MAXY; i++)  for (j=0; j<MAXX; j++)
  1038.             know[j][i]=0;
  1039.         nap(2000);    
  1040.         draws(0,MAXX,0,MAXY); /* potion of forgetfulness */
  1041.         return;
  1042.  
  1043.     case 13: 
  1044.         lprcat("\nYou can't see anything!");  /* blindness */
  1045.         c[BLINDCOUNT]+=500;  
  1046.         return;
  1047.  
  1048.     case 14: 
  1049.         lprcat("\nYou feel confused"); 
  1050.         c[CONFUSE]+= 20+rnd(9); 
  1051.         return;
  1052.  
  1053.     case 21: 
  1054.         lprcat("\nYou don't seem to be affected");  
  1055.         return; /* cure dianthroritis */
  1056.  
  1057.     case 22: 
  1058.         lprcat("\nYou feel a sickness engulf you"); /* poison */
  1059.         c[HALFDAM] += 200 + rnd(200);  
  1060.         return;
  1061.  
  1062.     case 23: 
  1063.         lprcat("\nYou feel your vision sharpen");    /* see invisible */
  1064.         c[SEEINVISIBLE] += rnd(1000)+400;
  1065.         monstnamelist[INVISIBLESTALKER] = 'I';  
  1066.         return;
  1067.     };
  1068.     bottomline();        /*    show new stats        */
  1069.     return;
  1070. }
  1071.  
  1072. /*
  1073.     *******
  1074.     OSCROLL
  1075.     *******
  1076.  
  1077.     function to process a magic scroll
  1078.  */
  1079. oscroll(typ)
  1080. int typ;
  1081. {
  1082.     lprcat("\nDo you ");
  1083.     if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); 
  1084.     lprcat("(t) take it"); 
  1085.     iopts();
  1086.     while (1) switch(getcharacter()) {
  1087.     case '\33':
  1088.     case 'i':    
  1089.         ignore();  
  1090.         return;
  1091.  
  1092.     case 'r':    
  1093.         if (c[BLINDCOUNT]) break;
  1094.         lprcat("read"); 
  1095.         forget();
  1096.         if (typ==2 || typ==15)  { 
  1097.             show1cell(playerx,playery); 
  1098.             cursors(); 
  1099.         }
  1100.         /*    destroy it    */    read_scroll(typ);  
  1101.         return;
  1102.  
  1103.     case 't':    
  1104.         lprcat("take"); 
  1105.         if (take(OSCROLL,typ)==0)    forget();    /*    destroy it    */
  1106.         return;
  1107.     };
  1108. }
  1109.  
  1110. /*
  1111.     data for the function to read a scroll
  1112.  */
  1113. static int xh,yh,yl,xl;
  1114. static char curse[] = { 
  1115.     BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
  1116.     LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM };
  1117. static char exten[] = { 
  1118.     PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT,
  1119.     INVISIBILITY, CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP };
  1120. char time_change[] = { 
  1121.     HASTESELF,HERO,ALTPRO,PROTECTIONTIME,DEXCOUNT,
  1122.     STRCOUNT,GIANTSTR,CHARMCOUNT,INVISIBILITY,CANCELLATION,
  1123.     HASTESELF,AGGRAVATE,SCAREMONST,STEALTH,AWARENESS,HOLDMONST,HASTEMONST,
  1124.     FIRERESISTANCE,GLOBE,SPIRITPRO,UNDEADPRO,HALFDAM,SEEINVISIBLE,
  1125.     ITCHING,CLUMSINESS, WTW };
  1126. /*
  1127.  *    function to adjust time when time warping and taking courses in school
  1128.  */
  1129. adjtime(tim)
  1130. register long tim;
  1131. {
  1132.     register int j;
  1133.     for (j=0; j<26; j++)    /* adjust time related parameters */
  1134.         if (c[time_change[j]])
  1135.             if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1;
  1136.     regen();
  1137. }
  1138.  
  1139. /*
  1140.     function to read a scroll
  1141.  */
  1142. read_scroll(typ)
  1143. int typ;
  1144. {
  1145.     register int i,j;
  1146.     if (typ<0 || typ>=MAXSCROLL) return;  /* be sure we are within bounds */
  1147.     scrollname[typ][0] = ' ';
  1148.     switch(typ)
  1149.     {
  1150.     case 0:    
  1151.         lprcat("\nYour armor glows for a moment");  
  1152.         enchantarmor(); 
  1153.         return;
  1154.  
  1155.     case 1:    
  1156.         lprcat("\nYour weapon glows for a moment"); 
  1157.         enchweapon(); 
  1158.         return;  /* enchant weapon */
  1159.  
  1160.     case 2:    
  1161.         lprcat("\nYou have been granted enlightenment!");
  1162.         yh = min(playery+7,MAXY);    
  1163.         xh = min(playerx+25,MAXX);
  1164.         yl = max(playery-7,0);        
  1165.         xl = max(playerx-25,0);
  1166.         for (i=yl; i<yh; i++) 
  1167.             for (j=xl; j<xh; j++)  
  1168.                 know[j][i]=1;
  1169.         nap(2000);    
  1170.         draws(xl,xh,yl,yh);    
  1171.         return;
  1172.  
  1173.     case 3:    
  1174.         lprcat("\nThis scroll seems to be blank");    
  1175.         return;
  1176.  
  1177.     case 4:    
  1178.         createmonster(makemonst(level+1));  
  1179.         return;  /*  this one creates a monster  */
  1180.  
  1181.     case 5:    
  1182.         something(level);    
  1183.         /* create artifact    */  
  1184.         return;
  1185.  
  1186.     case 6:    
  1187.         c[AGGRAVATE]+=800; 
  1188.         return; /* aggravate monsters */
  1189.  
  1190.     case 7:    
  1191.         gtime += (i = rnd(1000) - 850); /* time warp */
  1192.  
  1193.         if (i>=0) lprintf("\nYou went forward in time by %d mobuls",(long)((i+99)/100));
  1194.         else lprintf("\nYou went backward in time by %d mobuls",(long)(-(i+99)/100));
  1195.         adjtime((long)i);/* adjust time for time warping */
  1196.         return;
  1197.  
  1198.     case 8:    
  1199.         oteleport(0);      
  1200.         return;    /*    teleportation */
  1201.  
  1202.     case 9:    
  1203.         c[AWARENESS] += 1800;  
  1204.         return;    /* expanded awareness    */
  1205.  
  1206.     case 10:    
  1207.         c[HASTEMONST] += rnd(55)+12; 
  1208.         lprintf("\nYou feel nervous");
  1209.         return;    /* haste monster */
  1210.  
  1211.     case 11:    
  1212.         for (i=0; i<MAXY; i++)  
  1213.             for (j=0; j<MAXX; j++)
  1214.                 if (mitem[j][i])
  1215.                     hitp[j][i] = monster[mitem[j][i]].hitpoints;
  1216.         lprintf("\nYou feel uneasy");
  1217.         return;    /* monster healing */
  1218.  
  1219.     case 12:    
  1220.         c[SPIRITPRO] += 300 + rnd(200); 
  1221.         bottomline(); 
  1222.         return; /* spirit protection */
  1223.  
  1224.     case 13:    
  1225.         c[UNDEADPRO] += 300 + rnd(200); 
  1226.         bottomline(); 
  1227.         return; /* undead protection */
  1228.  
  1229.     case 14:    
  1230.         c[STEALTH] += 250 + rnd(250);  
  1231.         bottomline(); 
  1232.         return; /* stealth */
  1233.  
  1234.     case 15:    
  1235.         lprcat("\nYou have been granted enlightenment!"); 
  1236.         /* magic mapping */
  1237.         for (i=0; i<MAXY; i++) 
  1238.             for (j=0; j<MAXX; j++)  
  1239.                 know[j][i]=1;
  1240.         nap(2000);    
  1241.         draws(0,MAXX,0,MAXY);    
  1242.         return;
  1243.  
  1244.     case 16:    
  1245.         c[HOLDMONST] += 30; 
  1246.         bottomline(); 
  1247.         return; /* hold monster */
  1248.  
  1249.     case 17:    
  1250.         for (i=0; i<26; i++)    /* gem perfection */
  1251.             switch(iven[i])
  1252.             {
  1253.             case ODIAMOND:    
  1254.             case ORUBY:
  1255.             case OEMERALD:    
  1256.             case OSAPPHIRE:
  1257.                 j = ivenarg[i];  
  1258.                 j &= 255;  
  1259.                 j <<= 1;
  1260.                 if (j  > 255) 
  1261.                     j=255; /*double value */
  1262.                 ivenarg[i] = j;    
  1263.                 break;
  1264.             }
  1265.         break;
  1266.  
  1267.     case 18:    
  1268.         for (i=0; i<11; i++)    
  1269.             c[exten[i]] <<= 1; /* spell extension */
  1270.         break;
  1271.  
  1272.     case 19:    
  1273.         for (i=0; i<26; i++)    /* identify */
  1274.         {
  1275.             if (iven[i]==OPOTION)  
  1276.                 potionname[ivenarg[i]][0] = ' ';
  1277.             if (iven[i]==OSCROLL)  
  1278.                 scrollname[ivenarg[i]][0] = ' ';
  1279.         }
  1280.         break;
  1281.  
  1282.     case 20:    
  1283.         for (i=0; i<10; i++)    /* remove curse */
  1284.             if (c[curse[i]]) c[curse[i]] = 1;
  1285.         break;
  1286.  
  1287.     case 21:    
  1288.         annihilate();    
  1289.         break;    /* scroll of annihilation */
  1290.  
  1291.     case 22:    
  1292.         godirect(22,150,"The ray hits the %s",0,' ');    
  1293.         /* pulverization */
  1294.         break;
  1295.  
  1296.     case 23:  
  1297.         c[LIFEPROT]++;  
  1298.         break; /* life protection */
  1299.     };
  1300. }
  1301.  
  1302.  
  1303. opit()
  1304. {
  1305.     register int i;
  1306.     if (rnd(101)<81)
  1307.         if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5) {
  1308.             for (i=0;i<26;i++)
  1309.                 if (iven[i]==OWWAND) {
  1310.                     lprcat("\nYou float right over the pit");
  1311.                     return;
  1312.                 }
  1313.             if (level==MAXLEVEL-1) obottomless(); 
  1314.             else
  1315.                 if (level==MAXLEVEL+MAXVLEVEL-1) obottomless(); 
  1316.                 else
  1317.                 {
  1318.                     if (rnd(101)<20)
  1319.                     {
  1320.                         i=0;
  1321.                         lprcat("\nYou fell into a pit! You land right on top of a poor monster!\n");
  1322.                     }
  1323.                     else
  1324.                     {
  1325.                         i = rnd(level*3+3);
  1326.                         lprintf("\nYou fell into a pit!  You suffer %d hit points damage",(long)i);
  1327.                         lastnum=261; 
  1328.                         /* if he dies scoreboard will say so */
  1329.                     }
  1330.                     losehp(i); 
  1331.                     nap(2000);  
  1332.                     newcavelevel(level+1);  
  1333.                     draws(0,MAXX,0,MAXY);
  1334.                 }
  1335.         }
  1336. }
  1337.  
  1338. obottomless()
  1339. {
  1340.     lprcat("\nYou fell into a pit leading straight to HELL!");  
  1341.     beep(); 
  1342.     nap(3000);  
  1343.     died(262);
  1344. }
  1345.  
  1346. oelevator(dir)
  1347. int dir;
  1348. {
  1349.     playerx = rnd(MAXX-2);    
  1350.     playery = rnd(MAXY-2);
  1351.  
  1352.     if (dir==1) 
  1353.         newcavelevel(rund(level));
  1354.     else 
  1355.         newcavelevel(level + rnd(MAXLEVEL-1 - level));
  1356.     positionplayer();
  1357.     draws(0,MAXX,0,MAXY); 
  1358.     bot_linex();
  1359. }
  1360.  
  1361. ostatue()
  1362. {
  1363. }
  1364.  
  1365.  
  1366. omirror()
  1367. {
  1368. }
  1369.  
  1370. obook()
  1371. {
  1372.     lprcat("\nDo you ");
  1373.     if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); 
  1374.     lprcat("(t) take it"); 
  1375.     iopts();
  1376.     while (1) 
  1377.         switch(getcharacter()) {
  1378.         case '\33':
  1379.         case 'i':    
  1380.             ignore();    
  1381.             return;
  1382.  
  1383.         case 'r':    
  1384.             if (c[BLINDCOUNT]) break;
  1385.             lprcat("read");
  1386.             readbook(iarg[playerx][playery]);   
  1387.             /* no more book    */
  1388.             forget();
  1389.             return;
  1390.  
  1391.         case 't':    
  1392.             lprcat("take");  
  1393.             if (take(OBOOK,iarg[playerx][playery])==0)  forget();    /* no more book    */
  1394.             return;
  1395.         };
  1396. }
  1397.  
  1398. /*
  1399.     function to read a book
  1400.  */
  1401. readbook(arg)
  1402. register int arg;
  1403. {
  1404.     register int i,tmp;
  1405.  
  1406.     if (arg<=3) 
  1407.         i = rund((tmp=splev[arg])?tmp:1); 
  1408.     else {
  1409.         if (arg >= 21) 
  1410.             arg = 20;    /* # entries in splev = 21 */
  1411.         i = rnd( (tmp=splev[arg]-9) ?tmp:1 ) + 9;
  1412.     }
  1413.     spelknow[i]=1;
  1414.     lprintf("\nSpell \"%s\":  %s\n%s",
  1415.         spelcode[i],spelname[i],speldescript[i]);
  1416.     if (rnd(10)==4) {
  1417.         lprcat("\nYour int went up by one!"); 
  1418.         c[INTELLIGENCE]++; 
  1419.         bottomline(); 
  1420.     }
  1421. }
  1422.  
  1423. ocookie()
  1424. {
  1425.     char *p;
  1426.     lprcat("\nDo you (e) eat it, (t) take it"); 
  1427.     iopts();
  1428.     while (1) 
  1429.         switch(getcharacter()) {
  1430.         case '\33':
  1431.         case 'i':    
  1432.             ignore();    
  1433.             return;
  1434.  
  1435.         case 'e':    
  1436.             lprcat("eat\nThe cookie tasted good.");
  1437.             forget(); /* no more cookie    */
  1438.             if (c[BLINDCOUNT]) return;
  1439.             if (!(p=fortune(fortfile))) return;
  1440.             lprcat("  A message inside the cookie reads:\n"); 
  1441.             lprcat(p);
  1442.             return;
  1443.  
  1444.         case 't':    
  1445.             lprcat("take");  
  1446.             if (take(OCOOKIE,0)==0) forget();
  1447.             return;
  1448.         };
  1449. }
  1450.  
  1451.  
  1452. /* routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth 100* the argument */
  1453. ogold(arg)
  1454. int arg;
  1455. {
  1456.     register long i;
  1457.  
  1458.     i = iarg[playerx][playery];
  1459.  
  1460.     if (arg==ODGOLD) i *= 10;
  1461.     else if (arg==OMAXGOLD) i *= 100;
  1462.     else if (arg==OKGOLD) i *= 1000;
  1463.  
  1464.     lprintf("\nIt is worth %d!",(long)i);    
  1465.     c[GOLD] += i;  
  1466.     bottomgold();
  1467.     item[playerx][playery] = know[playerx][playery] = 0;/*destroy gold*/
  1468. }
  1469.  
  1470. ohome()
  1471. {
  1472.     register int i;
  1473.  
  1474.     nosignal = 1;    /* disable signals */
  1475.     for (i=0; i<26; i++) 
  1476.         if (iven[i]==OPOTION) 
  1477.             if (ivenarg[i]==21)
  1478.             {   /* remove the potion of cure dianthroritis from inventory */
  1479.                 iven[i]=0;    
  1480.                 clear(); 
  1481.                 lprcat("Congratulations.  You found the potion of cure dianthroritis!\n");
  1482.                 lprcat("\nFrankly, No one thought you could do it.  Boy!  Did you surprise them!\n");
  1483.                 if (gtime>TIMELIMIT) {
  1484.                     lprcat("\niHowever... the doctor has the sad duty to inform you that your daughter has died!\n");
  1485.                     lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad...\n");
  1486.                     nap(5000); 
  1487.                     died(269);
  1488.                 }
  1489.                 else {
  1490.                     lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
  1491.                     lprcat("Your daughter should be well on her way to recovery.\n");
  1492.                     nap(6000);
  1493.                     lprcat("\nThe potion is"); 
  1494.                     nap(3000); 
  1495.                     lprcat(" working!  The doctor thinks that\n");
  1496.                     lprcat("your daughter will recover in a few days.  Congratulations!\n");
  1497.                     beep(); 
  1498.                     nap(5000); 
  1499.                     died(263);
  1500.                 }
  1501.             }
  1502.  
  1503.     while (1) {
  1504.         clear(); 
  1505.         lprintf("Welcome home %s.  Latest word from the doctor is not good.\n",logname);
  1506.  
  1507.         if (gtime>TIMELIMIT) {
  1508.             lprcat("\nThe doctor has the sad duty to inform you that your daughter has died!\n");
  1509.             lprcat("You didn't make it in time.  In your agony, you kill the doctor,\nyour wife, and yourself!  Too bad...\n");
  1510.             nap(5000); 
  1511.             died(269);
  1512.         }
  1513.  
  1514.         lprcat("\nThe diagnosis is confirmed as dianthroritis.  He guesses that\n");
  1515.         lprintf("your daughter has only %d mobuls left in this world.  It's up to you,\n",(long)((TIMELIMIT-gtime+99)/100));
  1516.         lprintf("%s, to find the only hope for your daughter, the very rare\n",logname);
  1517.         lprcat("potion of cure dianthroritis.  It is rumored that only deep in the\n");
  1518.         lprcat("depths of the caves can this potion be found.\n\n\n");
  1519.         lprcat("\n     ----- press "); 
  1520.         standout("return");
  1521.         lprcat(" to continue, "); 
  1522.         standout("escape");
  1523.         lprcat(" to leave ----- ");
  1524.         i=getcharacter();  
  1525.         while (i!='\33' && i!='\n') 
  1526.             i=getcharacter();
  1527.         if (i=='\33') { 
  1528.             drawscreen(); 
  1529.             nosignal = 0; /* enable signals */
  1530.  
  1531.             return; 
  1532.         }
  1533.     }
  1534. }
  1535.  
  1536. /*    routine to save program space    */
  1537. iopts()
  1538. {    
  1539.     lprcat(", or (i) ignore it? ");    
  1540. }
  1541. ignore()
  1542. {    
  1543.     lprcat("ignore\n");    
  1544. }
  1545.